// BaseType
export type BaseType = string | number | boolean | undefined | null

// NormalObject
export interface IObj<T = any> {
  [key: string]: T
}

// IObjArray
export type IObjArray = Array<IObj>

// Vue custom props type
export type { PropType } from 'vue'

// http query
// export interface IHttpQuery {}

// Function
export type IFunc<T = any> = (...params: Array<any>) => T

// RefElement
export type IRefEl = IObj | null

// vuex mutations
export type IMutations<T = any> = {
  [key: string]: (state: IObj, value?: T) => void
}

/* 类型判断 */
export const hasVarType = (n: any) => {
  const type = typeof n
  if (type !== 'object') {
    return type.slice(0, 1).toUpperCase() + type.slice(1).toLowerCase()
  }
  return Object.prototype.toString.call(n).replace(/^\[object (\S+)]$/, '$1')
}
// String
export const hasVarString = (n: any) => hasVarType(n) === 'String'
// Number
export const hasVarNumber = (n: any) => hasVarType(n) === 'Number'
// Number --NaN
export const hasVarNaN = (n: any) => hasVarType(n) === 'Number' && n.toString() === 'NaN'
// Number --Infinity
export const hasVarInfinity = (n: any) => hasVarType(n) === 'Number' && /[+-]?[iI]nfinity/.test(n.toString())
// Boolean
export const hasVarBoolean = (n: any) => hasVarType(n) === 'Boolean'
// Array
export const hasVarArray = (n: any) => hasVarType(n) === 'Array'
// Object
export const hasVarObject = (n: any) => hasVarType(n) === 'Object'
// Date
export const hasVarDate = (n: any) => hasVarType(n) === 'Date'
// Symbol
export const hasVarSymbol = (n: any) => hasVarType(n) === 'Symbol'
// Map
export const hasVarMap = (n: any) => hasVarType(n) === 'Map'
// Set
export const hasVarSet = (n: any) => hasVarType(n) === 'Set'
// Undefined
export const hasVarUndefined = (n: any) => hasVarType(n) === 'Undefined'
// Null
export const hasVarNull = (n: any) => hasVarType(n) === 'Null'
// Function
export const hasVarFunction = (n: any) => hasVarType(n) === 'Function'
// RegExp
export const hasVarRegExp = (n: any) => hasVarType(n) === 'RegExp'
// Error
export const hasVarError = (n: any) => hasVarType(n) === 'Error'
// Promise
export const hasVarPromise = (n: any) => hasVarType(n) === 'Promise'

// 常用类型判断封装
export const hasVarHttpQuery = (query: string) => {
  const c = false
}

// HTMLElement
export type IEl =
  HTMLElement
  | HTMLAnchorElement
  | HTMLAreaElement
  | HTMLAudioElement
  | HTMLBaseElement
  | HTMLQuoteElement
  | HTMLBodyElement
  | HTMLBRElement
  | HTMLButtonElement
  | HTMLCanvasElement
  | HTMLTableCaptionElement
  | HTMLTableColElement
  | HTMLDataElement
  | HTMLDataListElement
  | HTMLModElement
  | HTMLDetailsElement
  | HTMLDivElement
  | HTMLDListElement
  | HTMLEmbedElement
  | HTMLFieldSetElement
  | HTMLFormElement
  | HTMLHeadingElement
  | HTMLHeadElement
  | HTMLHRElement
  | HTMLHtmlElement
  | HTMLIFrameElement
  | HTMLImageElement
  | HTMLInputElement
  | HTMLLabelElement
  | HTMLLegendElement
  | HTMLLIElement
  | HTMLLinkElement
  | HTMLMapElement
  | HTMLMenuElement
  | HTMLMetaElement
  | HTMLMeterElement
  | HTMLObjectElement
  | HTMLOListElement
  | HTMLOptGroupElement
  | HTMLOptionElement
  | HTMLOutputElement
  | HTMLParagraphElement
  | HTMLParamElement
  | HTMLPictureElement
  | HTMLPreElement
  | HTMLProgressElement
  | HTMLScriptElement
  | HTMLSelectElement
  | HTMLSlotElement
  | HTMLSourceElement
  | HTMLSpanElement
  | HTMLStyleElement
  | HTMLTableElement
  | HTMLTableSectionElement
  | HTMLTemplateElement
  | HTMLTextAreaElement
  | HTMLTimeElement
  | HTMLTitleElement
  | HTMLTableRowElement
  | HTMLTrackElement
  | HTMLUListElement
  | HTMLVideoElement
